const path = require("path");
window.shortCut = require(path.join(__dirname, "./src/tools/shortCut.js"))();
shortCut.init();
shortCut.alt(123,function(){
  ipcRenderer.send('openDevTools');
});

window.baseTools = require(path.join(__dirname, "./baseTools.js"));

const fs= require("fs");
const electron = require('electron');
const {ipcRenderer} = electron;
const {createRender,timeout} = require(path.join(__dirname, "./src/tools/CreateRender.js"));

window.desktopDots = require(path.join(__dirname, "./src/units/desktopDots.js"));
const tempPop = createRender(require(path.join(__dirname, "./src/units/popup.js")));
const tempCTip= createRender(require(path.join(__dirname, "./src/units/cTip.js")));
// timeout(function () {
//   const time = new Date().getHours();
//   if (time >=  23) {
//     tempPop(document.querySelector(".wrap"), {slot: tempCTip,data: {content: "警告", title: "您需要休息了！"}, delay: 1000});
//   }
// },5000)();
createRender(require(path.join(__dirname, "./src/units/search.js")))(document.querySelector("body"));

const dataSearchMusic = require(path.join(__dirname, "./src/units/searchMusic.js"));
const tempSearchMusic = createRender(dataSearchMusic);
tempSearchMusic(document.querySelector("body"));

const dataCmd = require(path.join(__dirname, "./src/units/cmd.js"));
const tempCmd = createRender(dataCmd);
tempCmd(document.querySelector("body"));

const tempImg = createRender(require(path.join(__dirname, "./src/units/desktopImg.js")));

let prevImg = null;
let imges;
window.currentImgSrc = null;
window.currentImgAviColor = [255,255,255,1];
window.pictrueCanvasCtx = require("./src/pictrue/pictrue.js");
try {
  imges = fs.readdirSync(path.join(__dirname, "./img"));
  currentImgSrc = imges[0];
  require("./src/music/music.js");
  if (currentImgSrc) {
    timeout(function () {
      imges.push(imges.shift())
      currentImgSrc = imges[0];
      pictrueCanvasCtx.load(currentImgSrc);
      tempImg(document.querySelector("body"));
    },3000)();
    timeout(function () {
      desktopDots.show()
    }, 80)();
  }
} catch (e) {
  console.log(e);
  alert("请执行 npm run getPicture 来爬取背景图片！");
}


